﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace RoboZip
{
    public static class ConsoleWriteProgramHints
    {
        public static void WriteDashedLine()
        { 
            Console.WriteLine(@"-------------------------------------------------------------------------------");
        }

        public static void WriteHeader()
        {
            Console.WriteLine(@"");
            WriteDashedLine();
            Console.WriteLine(@"              RoboZip :: Robust file zipping for windows");
            WriteDashedLine();
            Console.WriteLine(@"");
            Console.WriteLine(@"Startet: " + DateTime.Now);
            Console.WriteLine(@"");
        }

        public static void WriteShortHelp()
        {
            Console.WriteLine(@"        Simple Syntax :: ROBOZIP Source Destination ");
            Console.WriteLine(@"");
            Console.WriteLine(@"               Source :: Source Directory (drive:\path or \\server\share\path).");
            Console.WriteLine(@"          Destination :: Destination Directory (drive:\path or \\server\share\path).");
            Console.WriteLine(@"                 File :: File(s) to zip   (names/wildcards: default is ""*.*"").");
            Console.WriteLine(@"");
            Console.WriteLine(@"For more information type ROBOZIP /?");
            Console.WriteLine(@"");
            WriteDashedLine();
            Console.WriteLine(@"");
        }
        public static void WriteFullHelp()
        {
            Console.WriteLine(@"::");
            Console.WriteLine(@":: Options :");
            Console.WriteLine(@"::");
            Console.WriteLine(@"");
            WriteOption_MonitoringPeriod();
            WriteOption_Start();
            WriteOption_FileNamePattern();
            WriteOption_DeleteSource();
            WriteOption_UpdateDestination();
        }

        public static void WriteOption_MonitoringPeriod()
        {
            Console.WriteLine(@"   /MP:period of time :: Which period of time to monitor, only one switch");
            Console.WriteLine(@"                         is possible:");
            Console.WriteLine(@"                         n : last minute");
            Console.WriteLine(@"                         h : last hour");
            Console.WriteLine(@"                         d : last day");
            Console.WriteLine(@"                         w : last week");
            Console.WriteLine(@"                         m : last month");
            Console.WriteLine(@"                         y : last year");
            Console.WriteLine(@"                         a : all time, from the oldes file till now (default)");
            Console.WriteLine(@"                         Depending on the choosen period of time in the past,");
            Console.WriteLine(@"                         the name of the zip file may contain fragments of date");
            Console.WriteLine(@"                         and time, e. g.:");
            Console.WriteLine(@"                         A zip file containing the files of the last day must be");
            Console.WriteLine(@"                         named like 2011-05-21.zip, because there may be an ");
            Console.WriteLine(@"                         other file for the following day 2011-05-22.zip.");
            Console.WriteLine(@"                         For a variation of the zip file name, see switch /FNP.");
            Console.WriteLine(@"");
        }

        public static void WriteOption_Start()
        {
            Console.WriteLine(@"     /START:timestamp :: Timestamp to start the zip process (yyyy-mm-dd hh:nn:ss).");
            Console.WriteLine(@"                         If not used, the start depends on the monitoring period");
            Console.WriteLine(@"                         choosen. For ""last day"" the RoboZip will start at the");
            Console.WriteLine(@"                         very beginning of the following period, the actual day.");
            Console.WriteLine(@"                         If used, the process will start after the timestamp has");
            Console.WriteLine(@"                         elapsed and the choosen period is over and then run always");
            Console.WriteLine(@"                         at the same time. Example 1:");
            Console.WriteLine(@"                         /MP:n /START:2011-07-25 02:30:30 will start at the give");
            Console.WriteLine(@"                         time and then repeat the job always at x minutes and 30 sec.");
            Console.WriteLine(@"                         Example 2: /MP:d /START:2011-12-13 01:30:00 will start");
            Console.WriteLine(@"                         at the give time and then repeat the job always at 1:30 am");
            Console.WriteLine(@"                         Having defined a monitoring period, you may also set the");
            Console.WriteLine(@"                         timestamp into the past to force the program to zip the");
            Console.WriteLine(@"                         files of multiple consecutive time spans.");
            Console.WriteLine(@"                         ALWAYS USE FULL QUALIFIED DATE TIME VALUES IN THE FORMAT");
            Console.WriteLine(@"                         ""yyyy-mm-dd hh:nn:ss""");
            Console.WriteLine(@"");
        }

        public static void WriteOption_FileNamePattern()
        {
            Console.WriteLine(@"          /FNP:String :: File Name Pattern. Use this pattern to adapt the generated");
            Console.WriteLine(@"                         file name to your needs:");
            Console.WriteLine(@"                         ""...'yyyy'...'mm'...'ww'...'dd'...'hh'...'nn'""");
            Console.WriteLine(@"                         ...             : allowed characters for file names");
            Console.WriteLine(@"                         characters in quotes for");
            Console.WriteLine(@"                         'yyyy' : year");
            Console.WriteLine(@"                         'mm'   : month");
            Console.WriteLine(@"                         'ww'   : calendar week");
            Console.WriteLine(@"                         'dd'   : day");
            Console.WriteLine(@"                         'hh'   : hour");
            Console.WriteLine(@"                         'nn'   : minute");
            Console.WriteLine(@"");
        }

        public static void WriteOption_DeleteSource()
        {
            Console.WriteLine(@"                  /DS :: Delete Source files successfully added to the zip file.");
            Console.WriteLine(@"");
        }
    
        public static void WriteOption_UpdateDestination()
        {
            Console.WriteLine(@"                  /UD :: Update Destination files in zip archive.");
            Console.WriteLine(@"");
        }

        public static void WriteArgumentError(Job Job)
        {

            WriteHeader();

            Console.WriteLine(@"   Source: " + Job.SourcePath);
            Console.WriteLine(@"   Destination: " + Job.DestinationPath);
            if (Job.FileList != null)
            {
                Console.WriteLine(@"   Files:");
                foreach (var item in Job.FileList)
                {
                    Console.WriteLine(@"           " + item.ToString());
                }                
            }
            else
            {
                Console.WriteLine(@"   Files: *.*");
            }
            Console.WriteLine(@"::");
            Console.WriteLine(@"::Options:");
            Console.WriteLine(@"::");
            Console.WriteLine(@"   /MP:    " + Job.MonitoringPeriod);
            if (Job.Start != null)
            {
                Console.WriteLine(@"   /START: " + Job.Start.ToString());
            }
            else
            {
                Console.WriteLine(@"   /START: (not defined)");
            }

            Console.WriteLine(@"   /FNP:   " + Job.FileNamePattern);
            Console.WriteLine(@"   /DS:    " +Job.DeleteSource.ToString());
            Console.WriteLine(@"   /UD:    " + Job.UpdateDestination.ToString());
            Console.WriteLine(@"");
            WriteDashedLine();
            Console.WriteLine(@"");
            Console.WriteLine(@"   Error:  " + Job.ErrorDescription);
            Console.WriteLine(@"");
            WriteShortHelp();
        }
    }
}
